package com.mxchen.lottery.app.activity.command.query;

import cn.hutool.core.convert.Convert;
import com.alibaba.cola.dto.SingleResponse;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.mxchen.lottery.client.activity.dto.ActivityDTO;
import com.mxchen.lottery.client.activity.dto.ActivitySingleQry;
import com.mxchen.lottery.infr.gatewayimpl.activity.model.Activity;
import com.mxchen.lottery.infr.gatewayimpl.activity.mapper.ActivityMapper;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author hmchen
 */
@Component
public class ActivityGetQryExe {
    @Resource
    private ActivityMapper activityMapper;
    public SingleResponse<ActivityDTO> execute(ActivitySingleQry qry) {
        return SingleResponse.of(Convert.convert(ActivityDTO.class,
                activityMapper.selectOne(new LambdaQueryWrapper<Activity>(){{
                    eq(Activity::getActivityId,qry.getActivityId());
                }})));
    }
}
